package com.mdmedia.common.test;

import java.util.List;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import com.mdmedia.cms.entiy.base.User;
import com.mdmedia.common.dao.ICommonDaoService;

@Transactional
@Repository("userDao")
public class UserDaoImpl implements IUserDao {
	@Autowired
	@Qualifier("commonDaoService")
	private ICommonDaoService commonDaoService;
	
	@Override
	public User getUser(User user) {
		String sql="from com.mdmedia.cms.entiy.base.User u where u.userName='"+user.getUserName()+"' and u.password='"+user.getPassword()+"'";
		List list = commonDaoService.getListByHQL(sql, null);
		User u = (User)list.get(0);
		String id = u.getId();
		User u1 = (User)commonDaoService.get(User.class, "402881ef482239ce0148223a0c560000");
		System.out.println(u1.getUserName());
		System.out.println(id);
		return u1;
	}
	@Override
	public void delete(User user) {
		// TODO Auto-generated method stub
		String sql="delete from User u where u.userName='"+user.getUserName()+"' and u.password='"+user.getPassword()+"'";
		commonDaoService.delete(user);
	}
	
	@Override
	public void save(User user) {
		// TODO Auto-generated method stub
		commonDaoService.save(user);
	}
	
}
